package com.lagou.service.impl;

import com.lagou.service.HelloServiceAsync;
import org.apache.dubbo.config.annotation.Service;

import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;

@Service
public class HelloServiceAsyncImpl implements HelloServiceAsync {

    @Override
    public CompletableFuture<String> sayHello(String name) {
        return CompletableFuture.supplyAsync(new Supplier<String>() {
            @Override
            public String get() {
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                return "Hello " + name + "!";
            }
        });
    }

}
